package com.yt.demo.controller;

import org.apache.shiro.authz.annotation.RequiresGuest;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Set;

@RestController
public class RedisController {

    @Autowired
    private RedisTemplate redisTemplate;
    @RequiresRoles("admin")
    @RequestMapping("/keys")
    public String showkeys() {
        StringBuffer stringBuffer=new StringBuffer();
        Set keys1 = redisTemplate.keys("*");
        keys1.forEach( (key)->{
            stringBuffer.append(key.toString());
            stringBuffer.append("<br>");
        });
        return stringBuffer.toString();
    }
}
